<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:replace="nav :: navHeaderIFrameItem(~{::title})">
    <title>token明细</title>
</head>
<body>
    <div id="form_win">
        <form class="layui-form" lay-filter="formData" >
            <div class="layui-form-item">
                <label class="layui-form-label">token</label>
                <div class="layui-input-block">
                    <input type="text" name="token"  placeholder="token" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">业务类型</label>
                <div class="layui-input-block">
                    <input type="text" name="bizType" placeholder="业务类型" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">应用名</label>
                <div class="layui-input-block">
                    <input type="text" name="bizName" placeholder="应用名" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">部门名称</label>
                <div class="layui-input-block">
                    <input type="text" name="deptName" placeholder="部门名称" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">负责人</label>
                <div class="layui-input-block">
                    <input type="text" name="ownerName" placeholder="负责人" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">负责人邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="ownerEmail" placeholder="负责人邮箱" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="isDisabled" value="0" title="启用" disabled>
                    <input type="radio" name="isDisabled" value="1" title="禁用" disabled>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea  name="remark" placeholder="请输入内容" class="layui-textarea" readonly></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">关闭</button>
                </div>
            </div>
        </form>
    </div>
    <div th:include="nav::navFooterIFrameItem" ></div>
    <script>
        //此处采用路径截取方式（可以采用thymeleaf方式）
        let url= document.location.href;
        let urlList = url.split('/');
        let id = urlList[urlList.length-1];

        layui.use(['form'], function() {
            //引入layui from模块
            let form = layui.form
            ,$ = layui.$;

            //初始化数据
            $.ajax({
                type: "get",//方法类型
                url: "/token/detail/"+id,
                dataType: "json",//预期服务器返回的数据类型
                success:function(result){
                    if(result.code===0){
                        let data = result.data;
                        $('input[name=isDisabled][value='+(data.isDisabled?"1":"0")+']').removeAttr("disabled");
                        $('input[name=isDisabled][value='+(data.isDisabled?"1":"0")+']').attr("checked",true);
                        form.val('formData',data);;
                        form.render(); //更新全部
                    }else{
                        top.layer.msg(result.msg, {
                            icon: 2,
                            time: 3000 //如果不配置，默认是3秒
                        });
                    }
                },
                error : function(e){
                    top.layer.msg('服务异常');
                }
            });

            //明细关闭
            form.on('submit(formDemo)', function(data){
                close_layer();
                return false;
            });

            //关闭弹窗
            function close_layer() {
                let index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        })


    </script>
</body>
</html>